<?php
/**
 * 
 * Enter description here ...
 * @var unknown_type
 */
use Fox\Document;
$xview = \Xview::instance();

$docid = 4232;
$className = Hive\Ressource::className();
$grouping_id = 4279;
$grouping_type = Hive\Ressource::className();
/*
$docid = $xview->val('docid');
$className = $xview->val('classname');
$grouping_id = $xview->val('inlineid');
$grouping_type = $xview->val('grouping');
if(empty($grouping_type)) {
	$grouping_type = $className::DOC_GROUPING;
}
*/

$document = Fox\Dao::load(Document::className(),$docid);

$status = new \Fox\Background\JsonStatusReporter(
	"Generating Document Index for document : $docid & ressource = $grouping_id",
	array(
		'Starting Indexation',
		'Finding new Words',
		'Adding Words to dictionnary',
		'Saving Matches',
		'Indexation Complete',
	)
);
/*
$searchEngine = new \Fox\SearchEngine();
$searchEngine->add($document,$grouping_id,$grouping_type);
echo "Indexing Initialize";
*/
\Fox\Background\Task::run($status, function ($status) use ($document,$grouping_id,$grouping_type)  {
	$status->start();
	$searchEngine = new \Fox\SearchEngine();
	$searchEngine->add($document,$grouping_id,$grouping_type,$status);
});

echo "Indexing Launched";